<?php
include('modules/modinit.php');
$mtNews = tPreset.'m_news';

// If page is to view the post
if($getsPage == 'post')
{
	// Id is set and not empty
	if(!empty($getsId))
	{
		$q[$sid] = mysql_query("SELECT * FROM ".$mtNews." WHERE id = '".sql($getsId, 0)."'")or die(mysql_error());
		$m[$sid] = mysql_fetch_object($q[$sid]);
		
        $title = v($m[$sid]->title);
		$trap1 = v($m[$sid]->content).'<br />';
        $trap2 = 'Posted by '.v($m[$sid]->author).' on '.v($m[$sid]->date);
	}
	else
	{
		$trap = 'This post does not exist.';
	}
    
    echo block($title, $trap1, $block['tmp'], $trap2);
}
else
{
	$q[$sid] = mysql_query("SELECT * FROM ".$mtNews." ORDER BY id DESC")or die(mysql_error());
	while($m[$sid] = mysql_fetch_object($q[$sid]))
	{
        $title = '<a href="index.php?id='.id.'&s2p=post&s2id='.v($m[$sid]->id).'">'.v($m[$sid]->title).'</a>';
        $trap1 = v($m[$sid]->content);
        $trap2 = 'Posted by '.v($m[$sid]->author).' on '.v($m[$sid]->date);
        
        echo block($title, $trap1, $block['tmp'], $trap2);
	}
}
